package com.gs.wzweather.controller;

import com.gs.wzweather.bo.Response;
import com.gs.wzweather.service.StatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "statistics")
public class StatisticsController {
    Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    StatisticsService statisticsService;

    /*
    查询统计表的资料 过去3小时（Pre_Sum_3h）、过去6小时（Pre_Sum_3h）、过去12小时（Pre_Sum_3h），过去24小时（Pre_Sum_3h）降雨量
    @param
        staIds:多个站号之间用逗号拼接
        time:20171020102000
        element:查询要素 参照关系型数据库表结构->10分钟资料统计表
    @return
        returnCode==0 查询成功
        returnCode==-1 查询失败
     */

    @RequestMapping("query")
    @ResponseBody
    public Response queryWzWea(String time, String element) {
        logger.info("queryWea->{}", time + "," + element);
        return statisticsService.getWea(time, element);
    }
}
